package com.senior.sendmessage.controller.wechat;

import com.senior.sendmessage.event.EventDemo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author baijiliang
 * @date 2022年07月13日 22:32
 */
@Slf4j
@Component
public class ListenerServicedemo {
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    @EventListener
    public void listener(EventDemo build) {
        log.info("监听到事件：【{}】",build.getFlag());
        applicationEventPublisher.publishEvent("结果");
    }
    /**
     * @author baijiliang
     * @date 2022/7/23 16:30
     * @param str
     * 不建议在监听中继续监听
     */
    @EventListener
    public void listener1(String str) {
        log.info("再次监听到事件：【{}】",str);
    }
}
